package com.ethannhu.todaynews.entity.response

import com.ethannhu.todaynews.model.BaseViewModel

/**
 * 详情网络请求解析类
 */
class DetailResponse<T> : BaseResponse() {
    /**
     * 真实数据
     * 类型为泛型
     */
    var data: T? = null
}

suspend fun <T> DetailResponse<T>.onSuccess(viewModel: BaseViewModel, action: suspend (data: T?) -> Unit) {
    if (isSuccess) {
        action(data)
    } else {
        viewModel._response.value = this
    }

}